<template>
  <el-container style="height: 100vh; background-color: #f7f7f7">
    <!-- 左侧导航 -->
    <el-aside class="aside" :style="{ width: isCollapse ? '64px' : '255px' }">
      <div
        @click="isCollapse = !isCollapse"
        style="margin-bottom: 20px"
        class="toggle"
        :style="{ left: isCollapse ? '64px' : '255px' }"
      >
        <i class="el-icon-s-unfold" v-if="isCollapse"></i>
        <span v-else>
          <i class="el-icon-s-fold"></i>
          收起
        </span>
      </div>
      <div class="logo">
        <img
          src="../../assets/img/logo (1).png"
          v-if="isCollapse"
          class="logo1"
        />
        <div v-else>
          <img src="../../assets/img/logo (1).png" class="logo1" />
          <span class="logo_span">COOL-ADMIN</span>
        </div>
      </div>
      <el-menu
        default-active="1-4-1"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        :collapse="isCollapse"
        :router="true"
      >
        <!-- 1 -->
        <el-submenu index="1">
          <template slot="title">
            <i class="iconfont icon-diannao"></i>
            <span slot="title">工作台</span>
          </template>
          <el-menu-item-group>
            <!-- 1.1 -->
            <el-menu-item index="/admin/pre">
              <i class="iconfont icon-shoucang"></i>
              <span slot="title">组件预览</span>
            </el-menu-item>
          </el-menu-item-group>
          <!-- 1.2 -->
          <el-submenu index="1-2">
            <span slot="title">
              <i class="iconfont icon-pengyouquan"></i>
              组件库</span
            >
            <!-- 1.2.1 -->
            <el-menu-item index="/admin/Crud">
              <i class="iconfont icon-shoucang"></i>
              <span slot="title">crud 示例</span>
            </el-menu-item>
            <!-- 1.2.2 -->
            <el-menu-item index="/admin/quill">
              <i class="iconfont icon-shoucang"></i>
              <span slot="title">quill 富文本编辑器</span>
            </el-menu-item>
            <!-- 1.2.3 -->
            <el-menu-item index="/admin/Rich">
              <i class="iconfont icon-shoucang"></i>
              <span slot="title">文件上传</span>
            </el-menu-item>
          </el-submenu>
        </el-submenu>

        <!-- 2 -->
        <el-submenu index="2">
          <template slot="title">
            <i class="iconfont icon-shezhi"></i>
            <span slot="title">系统管理</span>
          </template>
          <!-- 2.1 -->
          <el-submenu index="2-1">
            <span slot="title">
              <i class="iconfont icon-quanxian"></i>
              权限管理</span
            >
            <!-- 1.2.1 -->
            <el-menu-item index="/admin/user">
              <i class="iconfont el-icon-user-solid"></i>
              <span slot="title">用户列表</span>
            </el-menu-item>
            <!-- 1.2.2 -->
            <el-menu-item index="/admin/menu">
              <i class="iconfont icon-liebiao2"></i>
              <span slot="title">菜单列表</span>
            </el-menu-item>
            <!-- 1.2.3 -->
            <el-menu-item index="/admin/role">
              <i class="iconfont icon-pengyouquan"></i>
              <span slot="title">角色列表</span>
            </el-menu-item>
          </el-submenu>

          <!-- 2.2 -->
          <el-submenu index="2-2">
            <span slot="title">
              <i class="iconfont icon-pengyouquan"></i>
              参数配置</span
            >
            <!-- 1.2.1 -->
            <el-menu-item index="/admin/parameter">
              <i class="iconfont icon-liebiao2"></i>
              <span slot="title">参数列表</span>
            </el-menu-item>
          </el-submenu>

          <!-- 2.3 -->
          <el-submenu index="2-3">
            <span slot="title">
              <i class="iconfont icon-shuju"></i>
              监控管理</span
            >
            <!-- 1.2.1 -->
            <el-menu-item index="/admin/jour">
              <i class="iconfont icon-zidianguanli"></i>
              <span slot="title">请求日志</span>
            </el-menu-item>
          </el-submenu>
        </el-submenu>

        <!-- 3 -->
        <el-submenu index="3">
          <template slot="title">
            <i class="iconfont icon-zidianguanli"></i>
            <span slot="title">字典管理</span>
          </template>
          <el-menu-item index="/admin/Dicti">
            <i class="iconfont icon-liebiao2"></i>
            <span slot="title">字典列表</span>
          </el-menu-item>
        </el-submenu>

        <!-- 4 -->
        <el-submenu index="4">
          <template slot="title">
            <i class="iconfont icon-mobankuangjia"></i>
            <span slot="title">框架教程</span>
          </template>
          <el-menu-item index="/admin/file">
            <i class="iconfont icon-zidianguanli"></i>
            <span slot="title">文档</span>
          </el-menu-item>
        </el-submenu>

        <!-- 5 -->
        <el-submenu index="5">
          <template slot="title">
            <i class="iconfont icon-faburenwu"></i>
            <span slot="title">任务管理</span>
          </template>
          <el-menu-item index="/admin/task">
            <i class="iconfont icon-liebiao2"></i>
            <span slot="title">任务列表</span>
          </el-menu-item>
        </el-submenu>

         <!-- 5 -->
        <el-submenu index="6">
          <template slot="title">
            <i class="iconfont icon-faburenwu"></i>
            <span slot="title">信息列表</span>
          </template>
          <el-menu-item index="/admin/Comty">
            <i class="iconfont icon-liebiao2"></i>
            <span slot="title">商品列表</span>
          </el-menu-item>
          <el-menu-item index="/admin/Order">
            <i class="iconfont icon-liebiao2"></i>
            <span slot="title">订单列表</span>
          </el-menu-item>
          
        </el-submenu>

      </el-menu>
    </el-aside>
    <!-- 左侧导航 -->

    <el-container>
      <!-- 顶部固定区域 -->
      <el-header style="height: 100px">
        <div class="header_top">
          <ul class="header_top">
            <li>
              <span class="iconfont icon-lingdang"></span>
            </li>
            <li>
              <el-button
                @click="drawer = true"
                type="primary"
                style="
                  width: 100%;
                  height: 100%;
                  background-color: rgba(0, 0, 0, 0);
                "
              >
                <span class="iconfont icon-w_huapan"></span>
                <el-switch v-model="value1"> </el-switch>
              </el-button>
              <el-drawer
                title="我是标题"
                :visible.sync="drawer"
                :with-header="false"
              >
                <span class="cha" @click="drawer = false">x</span>
                <div class="conte">
                  <div class="D1">
                    <h4>推荐</h4>

                    <div>
                      <el-radio-group v-model="radio1">
                        <el-radio-button label="蓝"></el-radio-button>
                        <el-radio-button label="红"></el-radio-button>
                        <el-radio-button label="黑"></el-radio-button>
                        <el-radio-button label="粉"></el-radio-button>
                      </el-radio-group>
                    </div>

                  </div>
                  <div class="D2">
                    <h4>自定义主色</h4>
                      <el-color-picker v-model="color"></el-color-picker>
                    <span style="color: #000">{{ color }}</span>
                  </div>
                  <div class="D3">
                    <h4>菜单分组显示</h4>
                    <el-switch v-model="value11"> </el-switch>
                  </div>
                  <div class="D4">
                    <h4>转场动画</h4>
                    <el-switch v-model="value2"> </el-switch>
                  </div>
                </div>
              </el-drawer>
            </li>
            <li>
              <el-popover placement="top" v-model="visible">
                <div class="rou_link">
                  <a href="#" @click="inof()"
                    ><span
                      class="el-icon-user"
                      style="color: #000; margin: 10px"
                    ></span
                    >用户中心 </a
                  ><br />
                  <a href="#" @click="remove()"
                    ><span
                      class="el-icon-switch-button"
                      style="color: #000; margin: 10px"
                    ></span
                    >退出</a
                  >
                </div>
                <el-button slot="reference">
                  <span style="color: #000">管理员</span>
                  <img src="../../assets/img/logo2.png" alt="" />
                </el-button>
              </el-popover>
            </li>
          </ul>
        </div>

        <div class="header_conter">
          <ul>
            <li>
              <router-link to="/admin/index">
                <i class="iconfont icon-shouyetianchong"></i>
                <span>首页</span>
              </router-link>
            </li>
            <li @click="prev">
              <i class="iconfont icon-jiantou"></i>
              <span>后退</span>
            </li>
          </ul>
        </div>
      </el-header>
      <!-- 顶部固定区域 -->

      <!-- 内容区域 -->
      <el-main>
        <router-view></router-view>
      </el-main>
      <!-- 内容区域 -->
    </el-container>
  </el-container>
</template>
<style lang="scss">
.el-submenu__title:hover {
  background-color: #4165d7;
}

.el-aside::-webkit-scrollbar {
  width: 0 !important;
}

.el-header {
  height: 110px;
  padding: 0;
}
.el-drawer__body {
  .cha {
    position: absolute;
    top: 20px;
    right: 40px;
    font-size: 30px;
    font-weight: 400;
    color: #000;
  }
  .conte {
    width: 80%;
    height: 600px;
    margin: 0 auto;
    margin-top: 100px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding: 30px 0;
    > div {
      width: 350px;
      height: 90px;
      margin-bottom: 10px;
      background-color: #f7f7f7;
      border: 1px #dcdfe6 solid;
      border-radius: 10px;
      box-sizing: border-box;
      padding: 15px 10px 10px 15px;
      display: flex;
      justify-content: flex-start;
      flex-wrap: wrap;
      h4 {
        width: 100%;
        line-height: 1;
        font-size: 18px;
        font-weight: 400;
        height: 20px;
        text-align: left;
        margin-bottom: 5px;
      }
      .el-switch {
        margin-top: 10px;
      }
      .el-radio-group {
        display: flex;
        width: 300px;
        justify-content: space-around;
        .el-radio-button {
        width: 40px;
        height: 30px;
        margin: 0 3px;
      } 
      }
      
    }
    .D1 {
      height: 120px;
    }
  }
}
</style>
<style lang="scss" scoped>
// 顶部
.header_top {
  width: 100%;
  height: 50px;
  background-color: #fff;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  ul {
    margin-right: 20px;

    li {
      margin: 0 10px;
      height: 45px;
      line-height: 45px;

      .iconfont {
        color: #000;
        font-size: 20px;
      }

      .icon-lingdang {
        color: #000;
        margin-left: 10px;
      }

      img {
        width: 32px;
        height: 32px;
        border-radius: 50%;
      }
      .el-button {
        border: none;
        padding: 0;
        background-color: #fff;
      }
    }

    li:nth-of-type(1) {
      width: 45px;
      text-align: center;
      border-radius: 5px;
      margin-right: 0;
    }

    li:nth-of-type(2) {
      margin-left: 5px;
      width: 90px;
      text-align: center;
      border-radius: 5px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    li:nth-of-type(3) {
      span {
        margin-right: 10px;
      }
    }

    li:nth-of-type(2):hover {
      background-color: #e5e5e5;
    }

    li:nth-of-type(1):hover {
      background-color: #e5e5e5;
    }
  }
}

.header_conter {
  width: 100%;
  height: 30px;
  margin: 10px 0;
  padding-left: 20px;

  ul {
    display: flex;

    li {
      padding: 0 3px;
      box-sizing: border-box;
      text-align: center;
      width: 60px;
      height: 30px;
      border-radius: 5px;
      background-color: #fff;
      margin-right: 20px;

      .iconfont {
        font-size: 14px;
        line-height: 30px;
        color: #000;
      }

      span {
        font-size: 14px;
        line-height: 30px;
        color: #000;
        margin-left: -5px;
      }
    }
  }
}

// 左侧菜单字体图标
.iconfont {
  margin-right: 10px;
  color: #fff;
}

.el-submenu__title:hover {
  background-color: #4165d7;
}

.el-menu-vertical-demo:not(.el-menu--collapse) {
  min-height: 400px;
}

// 展开按钮
.toggle {
  top: 0;
  line-height: 64px;
  height: 54px;
  box-sizing: border-box;
  display: block;
  position: fixed;
}

.el-menu-item-group__title {
  color: #fff;
}

// 展开按钮字体图标
.toggle .el-icon-s-unfold,
.toggle .el-icon-s-fold {
  width: 64px;
  color: #777;
  font-size: 22px;
  text-align: center;
}

.toggle .el-icon-s-fold {
  width: 40px;
  text-align: right;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  cursor: pointer;

  > div {
    display: flex;
    align-items: center;
  }
}

.el-icon-arrow-down {
  color: #fff;
}

.logo1 {
  height: 30px;
  width: 30px;
  vertical-align: center;
}

.logo_span {
  color: #fff;
  font-weight: 700;
  font-size: 26px;
  margin-left: 10px;
  font-family: inherit;
  white-space: nowrap;
}

.el-submenu__title {
  color: #fff;
}

.aside,
.el-menu-vertical-demo,
.el-menu,
.el-submenu li {
  background-color: #2f3447;
  color: #fff;
}

span {
  color: #fff;
}
</style>

<script>
export default {
  data() {
    return {
      isCollapse: true,
      value1: false,
      visible: false,
      drawer: false,
      value11: true,
      value2: true,
      color: "#4165d7",
       radio1: '蓝',
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    // 后退
    prev() {
      this.$router.go(-1);
    },
    // 个人中心
    inof() {
      this.$router.push("/admin/inof");
      console.log("个人中心");
    },
    // 退出登录
    remove() {
      this.$router.replace("/");
      // localStorage.removeltem("token")
      localStorage.removeItem("token");
    },
  },
};
</script>
